package com.infore.controller;

import com.infore.entity.User;
import com.infore.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author:wk
 * @date:Created in 13:39 2017\11\21 0021
 */
@Controller
@RequestMapping("/")
public class MainController {

    @Autowired
    private UserService userService;

    @RequestMapping("")
    public String index(){
        return "index";
    }

    @RequestMapping("/json")
    @ResponseBody
    public Map<String, String> json(){
        Map<String, String> result = new HashMap<String, String>();
        result.put("MarK", "hello");
        result.put("Ken", "Hehe");
        result.put("Fowafolo", "fool");
        return result;
    }

    @RequestMapping("/json1")
    @ResponseBody
    public List<String> json1(){
        return userService.getAllUsernames();
    }

    @RequestMapping("/findall")
    @ResponseBody
    public List<User> findall(){
        return userService.getAllUsername();
    }
}
